package service.impl;

import dao.JjzsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.Jjzs;
import service.JjzsService;

import java.util.List;

/**
 * 急救知识表业务逻辑实现类
 */
@Service
public class JjzsServiceImpl implements JjzsService {
    @Autowired
    private JjzsMapper jjzsMapper;

    @Override
    public Jjzs findJjzsById(Integer id) {
        return jjzsMapper.findJjzsById(id);
    }

    @Override
    public List<Jjzs> findAllJjzs() {
        return jjzsMapper.findAllJjzs();
    }

    @Override
    public List<Jjzs> findHotJjzs(int limit) {
        return jjzsMapper.findHotJjzs(limit);
    }

    @Override
    public List<Jjzs> searchJjzs(String keyword) {
        return jjzsMapper.searchJjzs(keyword);
    }

    @Override
    public int addJjzs(Jjzs jjzs) {
        if (jjzs.getViewCount() == null) {
            jjzs.setViewCount(0);
        }
        return jjzsMapper.addJjzs(jjzs);
    }

    @Override
    public int updateJjzs(Jjzs jjzs) {
        return jjzsMapper.updateJjzs(jjzs);
    }

    @Override
    public int incrementViewCount(Integer id) {
        return jjzsMapper.incrementViewCount(id);
    }

    @Override
    public int deleteJjzs(Integer id) {
        return jjzsMapper.deleteJjzs(id);
    }
}